import request from '@/utils/request';

const INDICATOR_BASE_URL = '/nljs/indicator';
const INDICATOR_CATE_BASE_URL = '/nljs/indicatorCategory';

const IndicatorAPI = {
  // 新增指标
  addIndicator(data: any) {
    return request({
      url: `${INDICATOR_BASE_URL}/add`,
      method: 'post',
      data: data,
    });
  },
  // 修改指标
  editIndicator(data: any) {
    return request({
      url: `${INDICATOR_BASE_URL}/update`,
      method: 'post',
      data: data,
    });
  },
  // 删除指标
  delIndicator(id: string | number) {
    return request({
      url: `${INDICATOR_BASE_URL}/delete/${id}`,
      method: 'post',
    });
  },
  // 分页查询指标
  getIndicatorPage(data: any) {
    return request({
      url: `${INDICATOR_BASE_URL}/page`,
      method: 'get',
      params: data,
    });
  },
  // 查询指标列表（无分页）
  getIndicatorAllList(data?: any) {
    return request({
      url: `${INDICATOR_BASE_URL}/list`,
      method: 'get',
      params: data,
    });
  },
  // 获取指标详情
  getIndicatorDetail(id: string | number) {
    return request({
      url: `${INDICATOR_BASE_URL}/${id}`,
      method: 'get',
    });
  },
  // 查询指标分类属性结构
  getIndicatorCategoryTree() {
    return request({
      url: `${INDICATOR_CATE_BASE_URL}/tree`,
      method: 'get',
    });
  },
  // 新增指标分类
  addIndicatorCategory(data: any) {
    return request({
      url: `${INDICATOR_CATE_BASE_URL}/add`,
      method: 'post',
      data: data,
    });
  },
  // 修改指标分类
  editIndicatorCategory(data: any) {
    return request({
      url: `${INDICATOR_CATE_BASE_URL}/update`,
      method: 'post',
      data: data,
    });
  },
  // 删除指标分类
  delIndicatorCategory(id: string | number) {
    return request({
      url: `${INDICATOR_CATE_BASE_URL}/delete/${id}`,
      method: 'post',
    });
  },
  // 获取指标分类详情
  getIndicatorCategoryDetail(id: string | number) {
    return request({
      url: `${INDICATOR_CATE_BASE_URL}/${id}`,
      method: 'get',
    });
  },
  getIndicatorCategoryAllList(data: any) {
    return request({
      url: `/${INDICATOR_CATE_BASE_URL}/list`,
      method: 'get',
      params: data,
    });
  },
};

export default IndicatorAPI;

/** 指标类型信息 */
export interface IndicatorInfo {
  id?: number | string;
  /** 指标名称 */
  name?: string;
  /** 指标编码 */
  code?: string;
  /** 统计表单 */
  formIds: string;
  /** 统计维度 */
  dimension?: string | number;
  /** 指标描述 */
  description?: string;
  /** 指标状态 */
  status?: string | number;
  /** 指标附件 */
  attachment?: string;
}

export interface IndicatorCategoryInfo {
  id?: number | string;
  parentId?: number | string;
  /** 指标分类名称 */
  name?: string;
  code?: string;
  sort?: number;
  remark?: string;
}
